﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    public class Factory
    {
        public static IDS p = null;
        static Factory() 
        {
            add(new DS_csv());
            add(new DS_xml());
            add(new DS_yaml());
            add(new DS_json());
            add(new DS_mock());
            add(new DS_DB());
        }
        static void add(IDS x)
        {
            x.next = p;
            p = x;
           
        }
        public static IDS gi(string name)
        {
            return p.IsReady(name);
        }        
        public static items CreateObject(string name)
        {
            items newInstance = null;
            if (name == "Book")
            {
                newInstance = new book();
            }
            if (name == "Magazine")
            {
                newInstance = new magazine();
            }
            return newInstance;

        }
    }
}
